﻿using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace socket服务器端
{
    public class ReadFile
    {

        public static string OpenFile()
        {
            try
            {
                OpenFileDialog openFileDialog = new OpenFileDialog();
                openFileDialog.Title = "打开传输的文件";
                openFileDialog.Filter = "(*.txt)|*.txt";

                if (openFileDialog.ShowDialog() == true)
                {
                    string selectedFilePath = openFileDialog.FileName;

                    // 读取文件内容
                    string ReadContent = File.ReadAllText(selectedFilePath);

                    return ReadContent;
                }
            }
            catch (Exception)
            {

                throw;
            }
            
            return null;
        }
    }
}
